package work20241218;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
 * @author zdl
 * @date 2024/12/18
 */
public class Demo1 {
    public static void main(String[] args) {
        String str = "abcabcabc";
        Map<Character, Integer> map = new HashMap<>();
        char[] charArray = str.toCharArray();
        for (char c : charArray) {
            boolean b = map.containsKey(c);
            if (b) {
                Integer integer = map.get(c);
                integer++;
                map.put(c, integer);
            } else {
                map.put(c, 1);
            }
        }
        Set<Map.Entry<Character, Integer>> entries = map.entrySet();
        for (Map.Entry<Character, Integer> entry : entries) {
            System.out.println(entry.getKey() + "---->" + entry.getValue());
        }
    }
}
